-
-
Notifications
You must be signed in to change notification settings - Fork 32k
bpo-37137: Fix test_asyncio: use TestCase.set_event_loop() #13779
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Replace asyncio.set_event_loop() with TestCase.set_event_loop() of test_asyncio.utils: this method calls TestCase.close_loop() which waits until the executor completes, to avoid leaking dangling threads. Inherit from test_asyncio.utils.TestCase rather than unittest.TestCase.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM and thank you very much.
You are jedi for tests fighting!
self.loop.close() | ||
asyncio.set_event_loop(None) | ||
super().tearDown() | ||
self.set_event_loop(self.loop) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@asvetlov: I'm not sure about this change, but since tests still pass, it seems like the change is safe.
To be clear: I have no idea if this PR fix the issue, since I'm unable to reproduce https://bugs.python.org/issue37137
Well, I modified regrtest to make a test fail if there is "dangling thread", so I know this issue very well. I also reported https://bugs.python.org/issue34037 And I wrote TestCase.close_loop() and TestCase.set_event_loop() :-) |
…13779) Replace asyncio.set_event_loop() with TestCase.set_event_loop() of test_asyncio.utils: this method calls TestCase.close_loop() which waits until the executor completes, to avoid leaking dangling threads. Inherit from test_asyncio.utils.TestCase rather than unittest.TestCase.
Replace asyncio.set_event_loop() with TestCase.set_event_loop() of
test_asyncio.utils: this method calls TestCase.close_loop() which
waits until the executor completes, to avoid leaking dangling
threads.
https://bugs.python.org/issue37137